package com.hxl.aop.config;

import com.networknt.schema.JsonSchema;
import com.networknt.schema.JsonSchemaFactory;
import com.networknt.schema.SpecVersion;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Json模板 校验配置类
 */
@Configuration
public class JsonSchemaConfiguration {

    private static final String SCHEMA_VALIDATION_FILE = "/validation.json";
//    private static final String SCHEMA_VALIDATION_FILE = "sql/app.sql";

    @Bean
    public JsonSchema jsonSchema() {
        ClassLoader classLoader = getClass().getClassLoader();
        System.out.println(classLoader);
//        getClass().getResourceAsStream("1");
        return JsonSchemaFactory
                .getInstance(SpecVersion.VersionFlag.V7)
                .getSchema(getClass()
//                        .getClassLoader()
                        .getResourceAsStream(SCHEMA_VALIDATION_FILE));
    }
}